from uuid import uuid4

from sqlalchemy import Column

from apps.db import BaseModel, String
from apps.utils import curtime

states = {
    'waitUpload': '等待上传扫描件',
    'waitApprove': '等待审核',
    'approved': '已审核',
    'confirmed': '已确认',
    'error': '错误',
}


class BankSideInfo(BaseModel):
    __tablename__ = 'tb_bank_side_info'
    custom_name = Column(String, comment='客户信息')
    baseWork_flow_name = Column(String, comment='工作流类型')
    business_key = Column(String, comment='业务单据号, 保持唯一')
    start_org_code = Column(String, comment='组织机构代码')
    option_user_name = Column(String, comment='操作人员')
    description = Column(String)
    task_id = Column(String, comment='任务id, 作为接口查询条件')
    cust_id = Column(String, comment='借款人id, 作为接口查询条件')
    create_time = Column(String)
    error_msg = Column(String, comment='错误信息')
    state = Column(
        String,
        comment="""状态， 分为：等待上传文件（刚从3.0系统拉取到数据）, 等待审核（已上传文件，完成房管局填报），错误（数据填报错误）,
        已审核(等待比较确认)， 已确认。
        """
    )

    def __init__(self, *args, **kwargs):
        super(BankSideInfo, self).__init__()
        for attr, value in kwargs.items():
            if attr in self.__column_name_list__() and getattr(self, attr) is None:
                setattr(self, attr, value)
